using System;
using System.IO;

namespace MH.WsdlWorks.ProjectModel
{
    public abstract class DirectoryNode : Node
    {
        public DirectoryNode() { }
        public DirectoryNode(INode parent, string name)
            : base(parent, name)
        {
            string path = this.GetPath();
            string uniquePath = Utilities.GetUniqueFolderName(path);

            System.Diagnostics.Debug.Assert(!Directory.Exists(uniquePath), "Directory already exists");
            Directory.CreateDirectory(uniquePath);

            if (path != uniquePath)
            {
                this.Name = Utilities.GetDirectoryNameFromPath(uniquePath);
            }
        }

        public abstract override void SetParent(INode parent);
    }
}
